extends "../ankeleiqi-1/ankeleiqi-1.gd"


func _extInit():
	._extInit()
	if isInManual():
		addSkill(sk1t1[1], sk1t1[0])
		addSkill(sk1t2[1], sk1t2[0])
	elif sk1 != 0:
		doChoiceSkill1()
	lv = 2             #等级的设置

var sk1t1 = ["线列战术·1", "攻击会优先锁定正前方的敌人(即同行)，对与自己同一行的敌人造成的伤害提高100%"]
var sk1t2 = ["线列战术·2", "攻击会优先锁定正前方的敌人(即同行)，对不与自己同一行的敌人造成的伤害提高50%"]

func doChoiceSkill1():
	var sk = get("sk1t%d"%sk1)
	addSkill(sk[1], sk[0])

func _upS():
	._upS()
	setAiCha(aiCha)

func setAiCha(cha):
	if cha.cell.y == cell.y:
		aiCha = cha
		return
	var chas = []
	for i in getAllChas(1):
		if i.cell.y == cell.y and not i.isDeath:
			chas.append(i)
	if chas.empty():
		.setAiCha(cha)
	else:
		chas.sort_custom(self, "sortByDistance")
		aiCha = chas[0]
		$ui / Label.text = "%s|%s" % [name, aiCha.name]
	
func _onAtkChara(atkInfo):
	._onAtkChara(atkInfo)		
	if sk1 == 1 and atkInfo.hitCha.cell.y == cell.y:
		atkInfo.factor += 1
	if sk1 == 2 and atkInfo.hitCha.cell.y != cell.y:
		atkInfo.factor += 0.5